// flocking_render.vs
// OpenGL SuperBible
// Example of using transform feedback to implement flocking
// Program by Graham Sellers.

// Flocking render vertex shader
#version 330

// Model-view-projection matrix
uniform mat4 mvp;
uniform int base_size;
uniform float depth_divisor;

// Instanced attributes (position and velocity of the flock member)
layout (location = 0) in vec3 instance_position;

// Output color from the vertex shader
flat out vec4 vs_color;

void main(void)
{
    vec4 pos = vec4(instance_position, 1.0);
    
    gl_PointSize = base_size - (instance_position.z / depth_divisor);
    
    vs_color = vec4(instance_position, 1.0f);

    // Output position
    gl_Position = mvp * pos;
}
